package net.wofly.right.service;

import java.util.List;
import java.util.Map;

import net.wofly.common.persistence.PageWrapper;
import net.wofly.common.util.ReturnBean;
import net.wofly.right.domain.Organization;
import net.wofly.right.domain.User;
import net.wofly.right.dto.CustomDto;

public interface IOrganizationService {
    
    /**
     * 增加或修改
     *
     * @param entity
     * @return
     */
    public Organization save(Organization entity);
    
    /**
     * 删除
     *
     * @param entity
     * @return
     */
    public void delete(Organization entity);
    
    /**
     * 根据主键ID删除
     *
     * @param key
     * @return
     */
    public void delete(String key);
    
    /**
     * 根据主键查询
     *
     * @param key
     * @return
     */
    public Organization findOne(String key);
    
    public List<Organization> save(List<Organization> entityList);
    
    List<Organization> findByStatus(Integer status);
    
    Organization findByOrganizationCode(String organizationCode);
    
    List<Organization> findAll();

    /**
     * 添加客户信息
     * 添加客户信息时，带有联系人信息，联系人信息作为客户下的用户来处理
     * 
     * 客户组织机构ID与userID值相同
     * 
     * @param organization
     * @return
     */
    public ReturnBean<Organization> addCompanyCustomer(Organization organization)  ;
    
    /**
     * 获取客户信息详情
     * 
     * 
     * @param userID
     * @return
     */
    public ReturnBean<User> getCustomer(String userID)  ;
    
    /**
     * 
     * 客户高级查询接口
     * 
     * 
     * @param name
     * @param mobile
     * @param customType
     * @param followUserID
     * @return
     */
    public ReturnBean<PageWrapper<Organization>> getCustomerByCondition(String name, String mobile, String customType, String followUserID, Integer pageNum, Integer pageSize) ;
    
    /**
     * 获取所有企业客户，以Map形式返回
     * 
     * @return
     */
    public Map<String ,Organization> getAllCampanyCustomerOrgMap() ;
    
    public List<Organization> findByWarehouseFlagAndStatus(Integer warehouseFlag ,Integer status);
    
    public List<Organization> findByWarehouseFlagAndStatusAndOrganizationCodeNot(Integer warehouseFlag ,Integer status,String organizationCode);
    
    List<Organization> findByOrganizationCodeStartingWithAndOrganizationCodeNot(String organizationCode);
    
    /**
     * 保存客户信息
     * 添加客户信息时，带有联系人信息，联系人信息作为客户下的用户来处理
     * 
     * 客户组织机构ID与userID值相同
     * 
     * @param organization
     * @return
     */
    public ReturnBean<String> saveCustomer(CustomDto customDto)  ;
    
    
    /**
     * 获取客户信息详情
     * 
     * 
     * @param customUserID
     * @return
     */
    public ReturnBean<CustomDto> getCustomerDto(String customUserID)  ;
    
    /**
     * 查询所有客户
     * 按条件分页获取客户信息
     * 
     * 
     * @param salesUserID
     * @param customName
     * @param linkMan
     * @param mobile
     * @param pageNum
     * @param pageSize
     * @return
     */
    public ReturnBean<PageWrapper<Organization>> findAllCustomerByPage(String customName , String linkMan ,String mobile ,String organizationType ,Integer pageNum, Integer pageSize)  ;
    
    public ReturnBean<PageWrapper<Organization>> findMyCustomerByPage(String salesUserID, String customName , String linkMan ,String mobile ,String organizationType ,Integer pageNum, Integer pageSize)  ;
    
    public ReturnBean<PageWrapper<Organization>> findSubOrgsByOrgCode(String orgCode, Integer status, Integer pageNum, Integer pageSize);
    
    public ReturnBean<Organization> modifyOrganization(Organization organization);
    
    public ReturnBean<PageWrapper<User>> findSubUsersByOrgCode(String orgCode, Integer status, Integer pageNum, Integer pageSize);
    
    public ReturnBean<Organization> addSubOrganization(String parentOrganizationID, Organization organization);
    
    public ReturnBean<Void> deleteOrganization(String organizationID);
    
    /**
     * 返回树形结构的组织机构
     *  
     * @param orgCode
     * @param status
     * @return
     */
    public ReturnBean<List<Organization>> findOrgTreeByOrgCode(String orgCode ,Integer status);
}
